using UnityEngine;
using System.Collections;

public class GUI : MonoBehaviour {
	
public GameObject player;
	public FSMMachine fsm;
	private bool bInitialized=false;
	
void Awake()
	{	

	
	}
	
void OnGUI()
	{
		if (!bInitialized) Initialize ();
		
		GUILayout.BeginArea(new Rect(10, 100, 100, 100));
		
		//display current state
		GUILayout.TextField(fsm.GetState());
		
		if (GUILayout.Button("Idle"))
		{
			fsm.SetState(FSMMachine.eFSMState.eStateIdle);
		}
		
		if (GUILayout.Button("Patrol"))
		{
			fsm.SetState(FSMMachine.eFSMState.eStatePatrol);
		}
		GUILayout.EndArea();
		
	}
	
	void Initialize()
	{
		bInitialized=true;
		player = GameObject.FindGameObjectWithTag("Player");
		Debug.Log ("player found by GUI script:" + player);
		fsm=(player.GetComponent("NPC")as NPC).fsm;
		Debug.Log ("FSM component located: " + fsm);
		
	}
}
